<?php

namespace App\Common\Traits;

/*
 * 获取用户个体信息组件
 * @auth Jinfeihu
 * 
 */

trait UsersTrait {

    public $userId;
    public $userName;

    public function __construct() {
        $userData = auth('api')->user();
        $this->setUserId($userData);
        $this->setUserName($userData);
    }

    private function setUserId($object) {
        $this->userId = $object->id ?? '';
    }

    private function setUserName($object) {
        $this->userName = $object->name ?? '';
    }

    public function getUserId() {
        return $this->userId;
    }

    public function getUserName() {
        return $this->userName;
    }

}
